package com.aplikata.evok.datamodel;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.aplikata.evok.bo.DomainPatient;
import com.aplikata.service.PublicService;
import com.aplikata.util.StringUtil;

/**
 * @ClassName: PatientDataModel
 * @Description: TODO
 * @author Huyun
 * @date 17. 5. 2012. 11:41:07
 */
public class DomainPatientDataModel extends ListDataModel<DomainPatient> implements SelectableDataModel<DomainPatient> {
	private PublicService publicService;

	public DomainPatientDataModel() {
	}

	public DomainPatientDataModel(PublicService publicService, List<DomainPatient> data) {
		super(data);
		this.publicService = publicService;
	}

	@Override
	public DomainPatient getRowData(String arg0) {
		if (StringUtil.isStrEmpty(arg0) || "null".equals(arg0))
			return null;

		return (DomainPatient) publicService.get(DomainPatient.class, Long.parseLong(arg0));
	}

	@Override
	public Object getRowKey(DomainPatient domainPatient) {
		return domainPatient.getId();
	}

	public PublicService getPublicService() {
		return publicService;
	}

	public void setPublicService(PublicService publicService) {
		this.publicService = publicService;
	}

}